package org.way.file.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.way.base.dto.GlobalDTO;
import org.way.file.service.IFileService;

import javax.annotation.Resource;
import java.io.IOException;

@RestController
@RequestMapping(value = "/file")
@Api(tags = "文件服务")
public class FileController {

    @Resource
    private IFileService fileService;

    @GetMapping("/upload")
    @ApiOperation("文件上传")
    public GlobalDTO<String> uploadFile(@RequestParam MultipartFile file) {
        return GlobalDTO.success(fileService.uploadFile(file));
    }

    @GetMapping("/exportDynamicWord")
    @ApiOperation("导出word")
    public void exportDynamicWord() {
        fileService.exportDynamicWord();
    }

    @GetMapping("/exportZip")
    @ApiOperation("导出Zip")
    public void exportZip() throws IOException {
        fileService.exportZip();
    }
}
